package ProjectYudisium;

import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

public class FrameUtamaMahasiswa extends JFrame {

    Container contentPane;
    private JLabel labeljdl1, labeljdl2, jdl, jd2;
    private JMenuBar menuBar;
    private JMenu menuDaftar, menuExit;
    private JMenuItem daftar, check, exitFrame;
    private Random random;

    public FrameUtamaMahasiswa() {
        setSize(100, 770);
        setLocation(230, 0);
        setTitle("FRAME PENDAFTAR YUDISIUM");

        setSize(600, 400);
        setLocation(380, 100);
        setTitle("FRAME PENDAFTARAN YUDISIUM");
        setResizable(true);
        setCursor(Cursor.HAND_CURSOR);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);

        menuBar = new JMenuBar();
        this.setJMenuBar(menuBar);

        menuDaftar = new JMenu("DAFTAR YUDISIUM");
        menuBar.add(menuDaftar);
        daftar = new JMenuItem("Formulir Pendaftaran");
        menuDaftar.add(daftar);
        daftar.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JDialog dialog = new JDialog();
                dialog.setSize(1000,770);
                dialog.setLocation(230,0);
                JDialog dialog1 = new JDialog();
                dialog1.setSize(880, 580);
                dialog1.setLocation(260,55);
                PanelDaftarYudisium daftarYudisium = new PanelDaftarYudisium();
                dialog1.add(daftarYudisium);
                dialog1.setVisible(true);
                dispose();
            }
        });
        check = new JMenuItem("Check Data");
        menuDaftar.add(check);
        check.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final JDialog tblePersonal = new JDialog();
                tblePersonal.setLayout(null);
                tblePersonal.setSize(700, 320);
                tblePersonal.setLocation(300, 100);
                tblePersonal.setVisible(true);
                JLabel jdl = new JLabel("DATA INPUTAN PENDAFATARN YUDISIUM");
                jdl.setFont(new Font("Harrington", 1, 20));
                jdl.setBackground(Color.BLACK);
                jdl.setBounds(135, 10, 600, 40);
//                jdl.setHorizontalAlignment(JLabel.CENTER);
                tblePersonal.add(jdl);

                Yudisium test1 = new Yudisium();
                JTextArea nim = new JTextArea();
                JTextArea nama = new JTextArea();
                try {
                    nim.setText("NIM       = " + test1.getNim());
                    nim.setEditable(true);
                    nim.setFont(new Font("Times New Roman", 1, 16));
                    nim.setBounds(15, 60, 300, 20);
                    nim.setBackground(Color.cyan);
                    tblePersonal.add(nim);
                    nama.setText("NAMA   = " + test1.getNama());
                    nama.setEditable(true);
                    nama.setFont(new Font("Times New Roman", 1, 16));
                    nama.setBounds(15, 80, 300, 20);
                    nama.setBackground(Color.cyan);
                    tblePersonal.add(nama);
                } catch (Exception ex) {
                    Logger.getLogger(PanelDaftarYudisium.class.getName()).log(
                            Level.SEVERE, null, ex);
                }
                JButton exit = new JButton("CLOSE");
                exit.setFont(new Font("Times New Roman", 1, 14));
                exit.setBounds(280, 230, 90, 35);
                tblePersonal.add(exit);
                exit.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        FrameUtamaMahasiswa fMHS = new FrameUtamaMahasiswa();
                        fMHS.setVisible(true);
                        tblePersonal.dispose();
                    }
                });
                tampilTabel();
                dispose();
            }

            public void tampilTabel() {
                String[] judulKolom = {"Program Studi", "Nomor HP", "Periode Yudisium",
                    "Fakultas", "DaftarNilai", "NaskahTA", "Peminjaman Lab",
                    "Peminjaman dari Dosen", "Laporan KP", "Surat KKN/KP", "File Surat Pinjaman"};
                JTable tabel = new JTable();
//                DefaultTableModel tabModel = new DefaultTableModel(data,judulKolom);

//              JTable tabel = new JTable(new Object[2][2], 
//                        new String[]{"Program Studi","Nomor HP","Periode Yudisium",
//                        "Fakultas","DaftarNilai","NaskahTA","Peminjaman Lab",
//                        "Peminjaman dari Dosen","Laporan KP","Surat KKN/KP","File Surat Pinjaman"});
//                tblePersonal.add(tabel);  
            }
        });

        menuExit = new JMenu("BACK");
        menuBar.add(menuExit);
        exitFrame = new JMenuItem("to MENU UTAMA");
        menuExit.add(exitFrame);
        exitFrame.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                PengendaliYudisium main = new PengendaliYudisium();
                main.setVisible(true);
                dispose();
            }
        });

        contentPane = getContentPane();
        contentPane.setLayout(null);
        contentPane.setBackground(Color.lightGray);

        JLabel logo = new JLabel(new ImageIcon("Pictures/usd.gif"));
        logo.setBounds(20, 15, 150, 120);
        add(logo);

        labeljdl1 = new JLabel();
        Font font = new Font("Charlemagne Std", 1, 22);
        labeljdl1.setText("UNIVERSITAS SANATA DHARMA");
        labeljdl1.setBounds(165, 40, 600, 50);
        labeljdl1.setFont(font);
        add(labeljdl1);

        labeljdl2 = new JLabel();
        labeljdl2.setText("YOGYAKARTA");
        labeljdl2.setBounds(280, 75, 600, 50);
        labeljdl2.setFont(font);
        add(labeljdl2);

        jdl = new JLabel("PENDAFTARAN YUDISIUM");
        random = new Random();
        jdl.setFont(new Font("Algerian", 1, 40));
        jdl.setBackground(new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
        jdl.setBounds(45, 40, 600, 300);
        add(jdl);

        jd2 = new JLabel("MAHASISWA");
        random = new Random();
        jd2.setFont(new Font("Algerian", 1, 50));
        jd2.setBackground(new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
        jd2.setBounds(135, 90, 600, 300);
        add(jd2);
    }
}
